/*
 * @Author: jiameng15
 * @Date: 2020-03-04 22:47:07
 * @Last Modified by: jiameng15
 * @Last Modified time: 2020-04-14 20:44:27
 */
<template>
  <div class="row-main">
    <el-button type="shenda" size="mini"   @click="initData" icon="el-icon-refresh">刷新数据</el-button>

    <el-table
      :data="tableData"
      :header-cell-style="{ 'background':$store.state.app.tableBgColor,'color':'#606266' }"
      align="center"
      ref="table"
      class="row-main-table"
      v-loading.fullscreen="mainTableLoading" element-loading-text="拼命加载中"
      element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.2)">
      <el-table-column prop="loginName" label="代理账号" align="center"></el-table-column>
      <el-table-column prop="mobileNumber" label="发送手机号码" align="center"></el-table-column>
      <el-table-column prop="insertTime" label="时间" align="center"></el-table-column>
    </el-table>
    <div :style="{'overflow-x': $store.state.app.screenWidth<992?'scroll':'none'}">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        class="row-main-pager"
        :current-page.sync="page.current"
        :page-size="page.size"
        :total="page.total"
        layout="total, sizes, prev, pager, next, jumper"
        background></el-pagination>
    </div>
  </div>
</template>

<script>
  import {
    getShortMessageDetail,// 获取短信详情列表
    deleteNotice,// 删除公告
  } from '@/api/getData'
  import {getStore, setStore} from '@/config/mUtils'
  import {subStringForExceptLetter} from '@/utils/utils'
  import Editor from '@/components/Editor'

  var qiniu = require('qiniu-js')
  var imgUrl = localStorage.getItem('image')
  export default {
    name: 'StockOut',
    data() {
      return {
        // 查询条件
        searchForm:{
          firstUserId:null, // 一级代理id
          type:'',          // 时间类型  本日DAY  本月 MONTH  上月LASTMONTH
        },
        searchLoading: false,
        mainTableLoading:false,
        // 分页
        page: {
          current: 1,
          size: 10,
          total: 0,
          ascs: [],
          descs: [],
        },
        //
        tablePage: {
          pageSize: 15,
          pageSizes: [5, 15, 20, 50, 100, 200, 500, 1000]
        },
        tableData: [],
        value: false,
        tableLoading: false,
        id: '',
      }
    },
    components: {
      Editor
    },
    watch: {

    },
    created() {
      this.searchForm.type = this.$route.query.type
      this.searchForm.firstUserId = this.$route.query.firstUserId
      console.log(this.searchForm)
      this.initData()
    },

    methods: {
      handleSizeChange(val) {
        this.page.size = val;
        this.page.current = 1;
        this.initData();
      },
      handleCurrentChange(val) {
        this.page.current = val;
        this.initData();
      },
      beforeinitData(){
        this.page.current = 1
        this.initData()
      },
      async initData(theKey) {
        this.mainTableLoading = true;
        this.searchForm.page = this.page;
        // console.log(this.$route)
        // sessionStorage.setItem(this.$route.path,JSON.stringify(this.searchForm))
        const returnData = await getShortMessageDetail(this.searchForm, {
          obj: this,
          key: 'tableLoading;' + theKey
        })

        this.tableData = []
        if (returnData._result) {
          // 数据回显
          returnData.data.records.map(item => {
            const data = {}
            data.loginName = item.loginName
            data.mobileNumber = item.mobileNumber
            data.insertTime = item.insertTime
            this.tableData.push(data)
          })
          this.tableLoading = false
          this.page.total = returnData.data.total
        }
        this.mainTableLoading = false;
      },
      resetForm(formName) {
        this.searchForm = {
          type:'',                //时间类型
          firstUserId:'',         //一级代理id
        }
      },
    },
  }
</script>
<style scoped lang="scss">

  .drawer_form{
    padding: 50px;
    overflow-y:auto;
  }
  .notice_drawer_form{
    width:100%;
  }
  .recentAdd li {
    list-style: none;
    float: left;
    margin-right: 5px;
    line-height: 15px;
  }

</style>
<style>
.el-drawer.ttb{
  width: 800px;
  left: 50%;
  margin-left: -400px;
  /* right:50%; */
}
</style>
